﻿	(function(){
		var d = document,
			isStrict = d.compatMode == "CSS1Compat",dd = d.documentElement,db = d.body,m = Math.max,
			ie = !!d.all,ua = navigator.userAgent.toLowerCase(),
			head = d.getElementsByTagName('head')[0],
			getWH = function(){
				return {h:(isStrict?dd:db).clientHeight,w:(isStrict?dd:db).clientWidth}
			},
			getS = function(){
				return {t:m(dd.scrollTop,db.scrollTop),l:m(dd.scrollLeft,db.scrollLeft)};	
			},
			getP = function(el){
				var	r={t:0,l:0},
					isGecko = /gecko/.test(ua),
					add = function(t,l){r.l+=l,r.t+=t},
					p = el,sTL = getS();
				if(el&&el!=db){
					if(el.getBoundingClientRect){
						var b = el.getBoundingClientRect();
						add(b.top + sTL.t - dd.clientTop,b.left+ sTL.l - dd.clientLeft);
					}else{
						var dv = d.defaultView;
						while(p){
							add(p.offsetTop,p.offsetLeft);
							var computStyle = dv.getComputedStyle( p, null );
							if(isGecko){
								var bl = parseInt(computStyle.getPropertyValue('border-left-width'),10)||0,
									bt = parseInt(computStyle.getPropertyValue('border-top-width'),10)||0;
								add(bt,bl);
								if(p!=el&&computStyle.getPropertyValue('overflow')!='visible')
									add(bt,bl);
							}
							p = p.offsetParent;
						}
						p = el.parentNode;
						while (p && p != db) {
							add(-p.scrollTop,-p.scrollLeft); 
							p = p.parentNode;
						}
					}
				}
				return r;
			},
			creElm = function(o,t,pN){
				var el = d.createElement(t||'div');
				for(var p in o){
					p=='style'?el[p].cssText=o[p]:el[p]=o[p];
				}
				return (pN||db).insertBefore(el,(pN||db).firstChild);
			},
			div = creElm({id:'ckepop',style:"position:absolute;z-index:100000;display:none"}),
			div1 = creElm({id:'ckepop',style:"position:absolute;z-index:100000;display:none;top:50%;left:50%;"}),
			timer,inputTimer,list,clist,as,texts={},
			tagImgs = ["jiathis.gif","jiathis1.gif","jiathis2.gif","jiathis3.gif","jiathis4.gif","jiathis5.gif","jiathis6.gif"],
			scripts = d.getElementsByTagName('script');
			for(var i=0,ci,Bn;ci=scripts[i++];){
				if(Bn=ci.src.match(/Bn=(\d)$/)){
					break;
				}
			}
		if(window.jiathis){
			creElm({href:'http://www.jiathis.com/code/css/css1.css',rel:'stylesheet',type:'text/css'},'link',head);
		}else{
			d.write('<link href="http://www.jiathis.com/code/css/css1.css" rel="stylesheet" type="text/css" /><a href="#" onmouseover="return $CKE.over(this)" onmouseout="return $CKE.out()" onmousemove="$CKE.move()" onclick="return $CKE.center()"><img src="http://www.jiathis.com/code/images/'+tagImgs[(Bn&&Bn[1])||0]+'" width="125" height="21" border="0" id="jiathis_a"/></a>');

		}
		$CKE = {
			pop : div,
			centerpop:div1,
			disappear : function(event){
				var evt = window.event||event,
					t = evt.srcElement||evt.target,
					contain = div1.contains?div1.contains(t):!!(div1.compareDocumentPosition(t) & 16),
					a = d.getElementById('jiathis_a');
				if(!contain&&t!=a){
					div1.style.display = 'none';
				}
			},
			over : function(a){
				if(!this.a){
					this.a = a;
					creElm({src:'http://www.jiathis.com/code/ckepop.js',charset:'utf-8'},'script',head);
				}else{
					var p = getP(this.a),
						wh = getWH(),
						tl = getS();
					with(div.style){
						display = "block";
						top = (p.t+this.a.offsetHeight + div.offsetHeight >wh.h+tl.t?p.t - div.offsetHeight - (ie?1:8):p.t+this.a.offsetHeight+1) + 'px';
						left = p.l +'px';
					}
				};
				return false;
			},
			out : function(){
				timer = setTimeout(function(){
					div.style.display = 'none';
				},100)
			},
			move : function(){
				clearTimeout(timer)
			},
			center : function(){
				div.style.display = 'none';
				if(!this.script){
					this.script = creElm({src:'http://www.jiathis.com/code/ckecenterpop.js',charset:'utf-8'},'script',head);
					db.style.position = 'static';
				}else{
					var tl = getS();
					div1.style.display = "block";
					div1.style.margin = (-div1.offsetHeight/2+tl.t)+"px "+(-div1.offsetWidth/2+tl.l)+"px";
					list = d.getElementById('ckelist'),
					clist = list.cloneNode(true),
					as = clist.getElementsByTagName('input');
					for(var i=0,ci;ci = as[i++];){
						texts[ci.value] = ci.parentNode;			
					}
				}
				return false;
			},
			choose : function(o){
				clearTimeout(inputTimer);
				inputTimer = setTimeout(function(){
					var s = o.value.replace(/^\s+|\s+$/,''),
						frag = d.createDocumentFragment();
					for(var p in texts){
						eval("var f = /"+(s||'.')+"/ig.test(p)");
						f&&frag.appendChild(texts[p].cloneNode(true));
					}
					list.innerHTML = '';
					list.appendChild(frag);
				},100)
			},
			centerClose : function(){
				div1.style.display = 'none'
			}
		};
		div.onmouseover = function(){clearTimeout(timer);}
		div.onmouseout = function(){$CKE.out();}
		ie?d.attachEvent("onclick",$CKE.disappear):d.addEventListener("click",$CKE.disappear,false);
		window.jiathis&&$CKE.center();
	})()
	function jiathis_sendto(m){
		window.open('http://www.jiathis.com/send/?webid='+m+'&url='+encodeURIComponent(location)+'&title='+encodeURIComponent(document.title),'')
		return false;
	}
	function jiathis_sendto1(m){
		window.open('http://www.jiathis.com/send/?webid='+m+'&url='+encodeURIComponent(document.referrer)+'&title='+encodeURIComponent('输入网页标题'),
			'toolbar=no,menubar=no,width=200,height=200')
		return false;
	}
  
  function jt_addBookmark(title) {
                     var url=parent.location.href;
                     if (window.sidebar) { 
                            window.sidebar.addPanel(title, url,""); 
                     } else if( document.all ) {
                     window.external.AddFavorite( url, title);
                     } else if( window.opera && window.print ) {
                     return true;
                     }
       }